<%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ page import="entity.PaymentRecord" %>
        <%@ page import="java.util.List" %>
            <%@ page import="java.text.SimpleDateFormat" %>
                <html>

                <head>
                    <title>缴费记录查询</title>
                    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
                        rel="stylesheet">
                    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css"
                        rel="stylesheet">
                    <style>
                        body {
                            background-color: #f8f9fa;
                            padding-top: 2rem;
                        }

                        .card {
                            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
                            border: none;
                        }
                    </style>
                </head>

                <body>
                    <div class="container">
                        <div class="row justify-content-center">
                            <div class="col-md-10">
                                <div class="d-flex justify-content-between align-items-center mb-4">
                                    <h2>缴费记录查询</h2>
                                    <form class="d-flex"
                                        action="${pageContext.request.contextPath}/admin/payment/records" method="get">
                                        <input type="number" class="form-control me-2" name="ownerId"
                                            placeholder="输入业主ID查询">
                                        <button class="btn btn-outline-primary" type="submit">查询</button>
                                    </form>
                                </div>

                                <div class="card">
                                    <div class="card-body">
                                        <div class="table-responsive">
                                            <table class="table table-hover">
                                                <thead class="table-light">
                                                    <tr>
                                                        <th>业主姓名</th>
                                                        <th>费用类型</th>
                                                        <th>金额</th>
                                                        <th>缴费日期</th>
                                                        <th>支付方式</th>
                                                        <th>状态</th>
                                                        <th>备注</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <% List<PaymentRecord> records = (List<PaymentRecord>)
                                                            request.getAttribute("records");
                                                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd
                                                            HH:mm:ss");
                                                            if(records != null) {
                                                            for(PaymentRecord record : records) {
                                                            %>
                                                            <tr>
                                                                <td>
                                                                    <%= record.getOwnerName() %>
                                                                </td>
                                                                <td>
                                                                    <%= record.getFeeTypeName() %>
                                                                </td>
                                                                <td>¥<%= record.getAmount() %>
                                                                </td>
                                                                <td>
                                                                    <%= sdf.format(record.getPaymentDate()) %>
                                                                </td>
                                                                <td>
                                                                    <%= record.getPaymentMethod() %>
                                                                </td>
                                                                <td>
                                                                    <span class="badge <%= "
                                                                        已支付".equals(record.getStatus()) ? "bg-success"
                                                                        : "bg-warning" %>">
                                                                        <%= record.getStatus() %>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <%= record.getRemark() !=null ? record.getRemark()
                                                                        : "" %>
                                                                </td>
                                                            </tr>
                                                            <% } } %>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
                </body>

                </html>